//
//  CategoryListViewController.m
//  BigJoy
//
//  Created by Rowling on 2017/6/14.
//  Copyright © 2017年 Rowling. All rights reserved.
//

#import "CategoryListViewController.h"
#import "CommonCollectionViewCell.h"

@interface CategoryListViewController ()<UICollectionViewDelegate,UICollectionViewDataSource>
@property (nonatomic,strong) UICollectionView * collectionView;
@end

@implementation CategoryListViewController

-(UICollectionView *)collectionView {
    if (_collectionView == nil) {
        UICollectionViewFlowLayout * layout = [[UICollectionViewFlowLayout alloc]init];
        layout.itemSize = CGSizeMake(XMW(170), XMW(240));
        layout.minimumInteritemSpacing = XMH(10);
        layout.sectionInset = UIEdgeInsetsMake(0, XMW(10), 0, XMW(10));
        _collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, self.view.bounds.origin.y + 32, SCREEN_WIDTH, self.view.bounds.size.height - 32) collectionViewLayout:layout];
        _collectionView.delegate = self;
        _collectionView.dataSource = self;
        _collectionView.backgroundColor = [UIColor whiteColor];
        [_collectionView registerNib:[UINib nibWithNibName:NSStringFromClass([CommonCollectionViewCell class]) bundle:nil] forCellWithReuseIdentifier:@"Cell"];
    }
    return _collectionView;
}

-(void)viewDidLoad {
    [super viewDidLoad];
    [self.view addSubview:self.collectionView];
    [self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(self.view);
        make.top.equalTo(self.view).offset(32);
    }];
    UIView * headView = [[UIView alloc]init];
    headView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:headView];
    [headView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self.view);
        make.height.equalTo(@32);
    }];
    UILabel * titleLabel = [XMSuperHelper XMLableWithColor:[UIColor blackColor] Title:@"WORKS" FontSize:13];
    UILabel * subTitlabel = [XMSuperHelper XMLableWithColor:[UIColor colorForHex:@"333333"] Title:@"作品" FontSize:11];
    subTitlabel.font = [UIFont fontWithName:@"PingFang-SC-Light" size:11];
    [subTitlabel sizeToFit];
    [headView addSubview:titleLabel];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(headView).offset(10);
        make.centerY.equalTo(headView);
    }];
    [headView addSubview: subTitlabel];
    [subTitlabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(titleLabel.mas_right).offset(10);
        make.centerY.equalTo(headView);
    }];
    UIView * lineView = [UIView new];
    [headView addSubview:lineView];
    lineView.backgroundColor = XMColor(220, 220, 220);
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.equalTo(headView);
        make.height.equalTo(@1);
    }];
}

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return 10;
}

-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
    return 1;
}

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    CommonCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];
    return cell;
}


@end
